package com.lap.framework.junit.shared.tool;

import com.lap.framework.common.tool.Named;
import java.nio.file.Paths;
import lombok.experimental.UtilityClass;

@UtilityClass
public final class ProjectUtil {

  private static final String SLASH = "/";
  private static final String TEST_JAVA = "/src/test/java/";
  private static final String TEST_RESOURCES = "/src/test/resources/";
  private static final String SRC_JAVA = "/src/main/java/";

  public static String getProjectDir() {
    return System.getProperty("user.dir");
  }

  public static String getJavaPath(String basePackage) {
    String packagePath = Named.periods2Path(basePackage);
    return Paths.get(getProjectDir(), SRC_JAVA, packagePath).toString();
  }

  public static String getTestPath(String packageName) {
    String packagePath = Named.periods2Path(packageName);
    return Paths.get(getProjectDir(), TEST_JAVA, packagePath).toString();
    //    return getProjectDir()
    //        + TEST_JAVA
    //        + (packagePath.endsWith(SLASH) ? packagePath : packagePath + SLASH);
  }

  public static String getCvsPath(String parentPath) {
    return Paths.get(getProjectDir(), TEST_RESOURCES, parentPath).toString();
    //    return getProjectDir()
    //        + TEST_RESOURCES
    //        + (parentPath.endsWith(SLASH) ? parentPath : parentPath + SLASH);
  }
}
